package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.FeedbackInfo;
import com.elder.business.service.IFeedbackInfoService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 反馈信息Controller
 * 
 * @author elder
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/feedbackInfo")
public class FeedbackInfoController extends BaseController
{
    @Autowired
    private IFeedbackInfoService feedbackInfoService;

    /**
     * 查询反馈信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String feedbackTitle, Integer isSolve, Integer pageNum, Integer pageSize)
    {
        return feedbackInfoService.selectFeedbackInfoList(feedbackTitle, isSolve, pageNum, pageSize);
    }

    /**
     * 导出反馈信息列表
     */
//    @Anonymous
//    @Log(title = "反馈信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FeedbackInfo feedbackInfo)
//    {
//        List<FeedbackInfo> list = feedbackInfoService.selectFeedbackInfoList(feedbackInfo);
//        ExcelUtil<FeedbackInfo> util = new ExcelUtil<FeedbackInfo>(FeedbackInfo.class);
//        util.exportExcel(response, list, "反馈信息数据");
//    }

    /**
     * 获取反馈信息详细信息
     */
    @Anonymous
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
    {
        return success(feedbackInfoService.selectFeedbackInfoByFeedbackId(feedbackId));
    }

    /**
     * 新增反馈信息
     */
    @Anonymous
    @Log(title = "反馈信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeedbackInfo feedbackInfo)
    {
        return toAjax(feedbackInfoService.insertFeedbackInfo(feedbackInfo));
    }

    /**
     * 修改反馈信息
     */
    @Anonymous
    @Log(title = "反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeedbackInfo feedbackInfo)
    {
        return toAjax(feedbackInfoService.updateFeedbackInfo(feedbackInfo));
    }

    /**
     * 删除反馈信息
     */
    @Anonymous
    @Log(title = "反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(feedbackInfoService.deleteFeedbackInfoByFeedbackIds(feedbackIds));
    }

    @Anonymous
    @GetMapping(value = "/updateSolve/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId,String isSolve)
    {
        return success(feedbackInfoService.updateFeedbackInfoSolveStatus(feedbackId,isSolve));
    }

    @Anonymous
    @RequestMapping("/resultNotice")
    public AjaxResult resultNotice(Long feedbackId, Integer isSolve, String notes)
    {
        return feedbackInfoService.feedBackResultNotice(feedbackId, isSolve,notes);
    }
}
